package com.goktech.mapper;

import com.goktech.entity.User;
import com.goktech.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;

/**
 * @ClassName testUserMapper
 * @Description TODO
 * @Author 邱华英
 * @Date 2022/10/3 22:41
 * @Version 1.0
 */

public class testUserMapper {
    SqlSession session = null;
    UserMapper userMapper = null;

    @Before
    public void before() throws IOException {
        session = SqlSessionUtil.getSqlSession();
        userMapper = session.getMapper(UserMapper.class);
    }

    @After
    public void after(){
        session.close();
    }

    @Test
    public void testInsertUser(){
        User u = new User(null,"1","1","1","1","1");
        System.out.println(userMapper.insertUser(u));
    }

    @Test
    public void testdeleteUser(){
        User u = new User(null,"1","1","1","1","1");
        System.out.println(userMapper.deleteUser(u));
    }

    @Test
    public void testupdateUser(){
        User u = new User(null,"1","1","123","1","1");
        System.out.println(userMapper.updateUser(u));
    }

    @Test
    public void testfindByZhanghaoUser(){
        User u = new User(null,"1","12","123","1","1");
        System.out.println(userMapper.findByZhanghao(u));
    }

    @Test
    public void testfindByAllUser(){
        System.out.println(userMapper.findByAll(6,10));
    }

    @Test
    public void testfindLikeZhanghaoUser(){
        User u = new User(null,"1","%12%","123","1","1");
        System.out.println(userMapper.findLikeZhanghao(u));
    }

    @Test
    public void testfindLikeUserNameUser(){
        User u = new User(null,"%1%","%12%","123","1","1");
        System.out.println(userMapper.findLikeUserName(u));
    }

    @Test
    public void testfindZhanghaoPasswordUser(){
        User u = new User(null,"1","1","123","1","1");
        System.out.println(userMapper.findZhanghaoPassword(u));
    }
}
